package com.yidu.InventoryManagement.mapper;


import com.yidu.InventoryManagement.entity.Fund;
import com.yidu.InventoryManagement.entity.SecurityStock;
import com.yidu.InventoryManagement.entity.Securlty;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @author 梁俊
 * @date 2022/12/5
 * &@version 1.0
 */
@Mapper
public interface SecurityStockMapper {
    //分页模糊查证券库存
     @Select(" SELECT ss.securityStockId,ss.fundId,ss.DATE,ss.securityId,ss.quantity,ss.unitCost,ss.money,ss.initialState,ss.Remark,sr.securityName FROM securityStock ss INNER JOIN SECURITY sr ON ss.`securityId`=sr.`securityId` where 1=1 AND sr.securityName LIKE #{securityName} AND DATE LIKE #{DATE} limit #{page},#{limit}")
    public List<SecurityStock> selectSecurityStock(Map map);


    /**
     * 查询证券库存id有没有值
     * @return
     */
     @Select("SELECT count(*) FROM securityStock")
     public int selectSecurityStockId();



    /**
     * 分页查行数 模糊查询后的行数 根据条件
     * @param map 对象
     * @return
     */
    @Select("SELECT COUNT(*) FROM securityStock ss INNER JOIN SECURITY sr ON ss.`securityId`=sr.`securityId` where 1=1 AND sr.securityName LIKE #{securityName} AND DATE LIKE #{DATE}")
    public int countSecurityStock(Map map);

    /**
     * 多个删除
     * @param securityStockId id
     * @return
     */
    public int deleteSecurityStock(List securityStockId);


    /**
     * 证券库存添加
     * @return
     */
    @Insert("insert into securityStock values(#{securityStockId},#{fundId},#{date},#{securityId},#{quantity},#{unitCost},#{money},#{initialState},#{Remark})")
    public int insertSecurityStock(SecurityStock securityStock);


    /**
     * 证券库存修改
     * @param securityStock 对象
     * @return
     */
    @Update("update securityStock set fundId=#{fundId},DATE=#{date},securityId=#{securityId},quantity=#{quantity},unitCost=#{unitCost},money=#{money},initialState=#{initialState},Remark=#{Remark} where securityStockId=#{securityStockId}")
    public int updatesecurityStock(SecurityStock securityStock);

    /**
     * 根据证券库存查询基金id,证券id，初期标识
     * @param securityStockId
     * @return
     */
    @Select("select fundId,securityId,initialState from securityStock where securityStockId=#{securityStockId}")
    public SecurityStock selectOne(String securityStockId);




    /**
     * 查询基金id放到下拉框
     * @return
     */
    @Select("SELECT fundId FROM securityStock")
    public List<SecurityStock> funIdSelect();

    /**
     * 查询证券库存id
     * @return
     */
    @Select("SELECT securityStockId FROM securityStock")
    public List<SecurityStock> securityStockIdSelect();


    /**
     * 根据证券库存id查询数据
     * @param securityStockId
     * @return
     */
    @Select("select * from securityStock where securityStockId=#{securityStockId}")
    public List<SecurityStock>  securityStockIdselectsecurityStock(String securityStockId);



    /**
     * 下拉表格的查询证券信息
     * @return list 集合
     */
    @Select("select * from security where 1=1 and securityName like #{securityName} limit #{page},#{limit}")
    public List<Securlty> selectSecurityyyy(Map map);

    /**
     * 下拉表格查询证券信息的行数
     */
    @Select("select count(*) from security where 1=1 and securityName like #{securityName}")
    public int selectSecurityCount(String securityName);


    /**
     * 查询基金id
     */
    @Select("select * from fund LIMIT #{page},#{limit}")
    public List<Fund> selectFundId(Map map);

    /**
     * 下拉表格查询基金信息的行数
     */
    @Select("select count(*) from fund")
    public int selectFund();



}
